<template>
  <div class="index">
    <go-top></go-top>
    <div class="DataSide">
      <ul>
        <li>
          <img src="@/assets/icon10.svg" alt="" @click="GoComment" />
          <p>1263</p>
        </li>
        <li>
          <img src="@/assets/icon15.svg" alt="" @click="2" />
          <p>1263</p>
        </li>
        <li>
          <img src="@/assets/icon16.svg" alt="" @click="3" />
          <p>1263</p>
        </li>
      </ul>
    </div>
    <div class="main">
      <!-- 主体 -->
      <div class="article">
        <!-- 文章 -->
        <div class="article-title">
          <div class="title-mes">
            <h3>{{Pdata.title}}</h3>
          </div>
          <div class="title-model">
            <div class="model"><span>来自板块:</span><span>{{Pdata.class  }}</span></div>
            <ul>
              <li><img src="@/assets/icon9.svg" alt=""><span>{{Pdata.pageView}}</span></li>
              <li><img src="@/assets/icon10.svg" alt=""><span>{{Pdata.pageView}}</span></li>
              <li><img src="@/assets/icon16.svg" alt=""><span>{{Pdata.pageView}}</span></li>
              <li><img src="@/assets/icon15.svg" alt=""><span>{{Pdata.pageView}}</span></li>
            </ul>
          </div>
          <div class="title-time">文章发表: {{Pdata.dataTime|Time}}</div>
        </div>
        <pre class="article-main" v-html="Pdata.article">

        </pre>
      </div>
      <div class="addCom">
        <!-- 添加评论区 -->
        <comment-tab @sendMessage="setMes"></comment-tab>
      </div>
      <div class="Com">
        <!-- 评论区 -->
        <div
          class="ComItem"
          v-show="commentData"
          v-for="(n, i) in commentData"
          :key="i"
        >
          <comment-count :Cdata="n" :Zindex="i"></comment-count>
        </div>
      </div>
    </div>
    <div class="alide">
      <!-- 侧边栏 -->
      <div>
        <!-- 二维码 -->
        <div class="QR">
          <img
            src="https://img-static.mihoyo.com/new_qrcode/qrcode_ys.png"
            alt=""
          />
          <div>
            <p>扫码下载米游社App</p>
            <p>了解提瓦特最新资讯</p>
          </div>
        </div>
        <div class="Aswiper">
          <!-- 小轮播图  -->
          <swiper class="swiper" :options="swiperOption1">
            <swiper-slide>
              <img
                src="https://upload-bbs.mihoyo.com/pc_ad/pc_ad_ys_game_record2.jpg"
                alt=""
              />
            </swiper-slide>
            <swiper-slide>
              <img
                src="https://upload-bbs.mihoyo.com/pc_ad/ys_signin.jpg"
                alt=""
              />
            </swiper-slide>
            <swiper-slide>
              <img
                src="https://upload-bbs.mihoyo.com/upload/2022/07/12/47d82d6cfff1199b47f592e2e0687567_6062346148197936188.jpg"
                alt=""
              />
            </swiper-slide>
          </swiper>
        </div>
        <div class="hotTalk">
          <div class="title">
            <span>每日热榜</span>
            <span>更多</span>
          </div>
          <ul>
            <li>
              <div
                class="img"
                style="
                  background-image: url(https://upload-bbs.mihoyo.com/upload/2022/06/04/253444466/f8c71c2ca793e09252b0b2e483dbb73c_6791292097792595601.jpg?x-oss-process=image/resize,s_600/quality,q_80/auto-orient,0/interlace,1/format,jpg);
                "
              ></div>
              <div>
                <p>
                  <span>同人图</span
                  >【水夜叉】不知道她叫什么名字，就叫她老婆吧字，就叫她老婆字，就叫她老婆
                </p>
              </div>
            </li>
            <li>
              <div
                class="img"
                style="
                  background-image: url(https://upload-bbs.mihoyo.com/upload/2022/06/04/253444466/f8c71c2ca793e09252b0b2e483dbb73c_6791292097792595601.jpg?x-oss-process=image/resize,s_600/quality,q_80/auto-orient,0/interlace,1/format,jpg);
                "
              ></div>
              <div>
                <p>
                  <span>同人图</span
                  >【水夜叉】不知道她叫什么名字，就叫她老婆吧字，就叫她老婆字，就叫她老婆
                </p>
              </div>
            </li>
            <li>
              <div
                class="img"
                style="
                  background-image: url(https://upload-bbs.mihoyo.com/upload/2022/06/04/253444466/f8c71c2ca793e09252b0b2e483dbb73c_6791292097792595601.jpg?x-oss-process=image/resize,s_600/quality,q_80/auto-orient,0/interlace,1/format,jpg);
                "
              ></div>
              <div>
                <p>
                  <span>同人图</span
                  >【水夜叉】不知道她叫什么名字，就叫她老婆吧字，就叫她老婆字，就叫她老婆
                </p>
              </div>
            </li>
          </ul>
          <!--  -->
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { Swiper, SwiperSlide } from "vue-awesome-swiper";
import "swiper/css/swiper.css";
import CommentModel from "@/components/CommentModel.vue";
import GoTop from "@/components/GoTop.vue";
import CommentTab from "@/components/CommentTab.vue";
import CommentCount from "@/components/CommentCount.vue";
import { set } from "vue";
export default {
  name: "swiper-example-pagination",
  title: "Pagination",
  components: {
    Swiper,
    SwiperSlide,
    CommentModel,
    GoTop,
    CommentTab,
    CommentCount,
  },
  data() {
    return {
      Pdata: {
        avatar: "https://img-static.mihoyo.com/avatar/avatar10014.png",
        userName: "西风快报员",
        userLevel: 17,
        dataTime: 1659403140000,
        class: "官方",
        module: "原神",
        title: "「焰色天河」祈愿：「琉焰华舞·宵宫(火)」概率UP！",
        article:
        `<img style="width:100%" alt="" src="https://upload-bbs.mihoyo.com/upload/2022/06/20/76387920/d160e303916dafeb0c7769be49ee89b0_4533498090504805250.png?x-oss-process=image//resize,s_600/quality,q_80/auto-orient,0/interlace,1/format,png" />

姆~旅行者们好！

酱酱今天在山谷里睡懒觉的时候，被一阵奇怪的歌声吵醒 ( °Д°) 超——大——声——

究竟是谁在山顶开歌会？

<img style="width:100%" alt="" src="https://upload-bbs.mihoyo.com/upload/2022/06/20/76387920/4799dddda03b63452a4ff6bc239b992a_8179227602188058676.jpg?x-oss-process=image//resize,s_600/quality,q_80/auto-orient,0/interlace,1/format,jpg" />

<img style="width:100%" alt="" src="https://upload-bbs.mihoyo.com/upload/2022/06/20/76387920/07145109d72dab9f26676ef722a3fe50_3459216823119861302.jpg?x-oss-process=image//resize,s_600/quality,q_80/auto-orient,0/interlace,1/format,jpg" />

<img style="width:100%" alt="" src="https://upload-bbs.mihoyo.com/upload/2022/06/20/76387920/fd45a47ee02fb62848239af65e7efa1a_8108242357390186904.jpg?x-oss-process=image//resize,s_600/quality,q_80/auto-orient,0/interlace,1/format,jpg" />

角色活动祈愿「鬼门斗宴」将于2022/06/21 18:00开启！活动期间，限定五星角色「花坂豪快·荒泷一斗(岩)」的祈愿获取概率将大幅提升，旅行者们不要错过哦~`






,
        images: [
          "https://upload-bbs.mihoyo.com/upload/2022/07/26/75276539/2508d400ba2e8494867e05259d04b6cd_4432750527329040643.jpg?x-oss-process=image//resize,s_600/quality,q_80/auto-orient,0/interlace,1/format,jpg",
          "https://upload-bbs.mihoyo.com/upload/2022/07/26/75276539/b715282d3609129d4f8ae178091286a1_3323430204500352293.png?x-oss-process=image//resize,s_600/quality,q_80/auto-orient,0/interlace,1/format,png",
        ],
        pageView: 300000,
        comment: 300000,
        like: 30000,
      },
      commentData: [
        // {
        //   avatar: "https://img-static.mihoyo.com/avatar/avatar10014.png",
        //   userName: "西风快报员",
        //   userLevel: 17,
        //   comment:
        //     '1241241241<img style="width:60px;margin-right:5px" src="/biaoqing/biaoqing1.png"><img style="width:60px;margin-right:5px" src="/biaoqing/biaoqing2.png">',
        // },
      ],
      swiperOption1: {
        autoplay: {
          delay: 2000,
          disableOnInteraction: false,
        },
      },
    };
  },
  methods: {
    scrollEvent(n) {
      console.log(n);
    },
    GoComment(){
      
      let com = document.getElementsByClassName('addCom')
      let comTop=com[0].offsetTop-100
      let top = document.body.scrollTop||document.documentElement.scrollTop
      if(comTop<top) return
      console.log(com)
      let to =setInterval(() => {
      document.body.scrollTop=document.documentElement.scrollTop = top+=50
      if(top>= comTop){
        clearInterval(to)
      }
      }, 10);
    },
    setMes(value,time) {
      if (!value.trim()) return;
      this.$set(this.commentData, this.commentData.length, {
        avatar: "https://img-static.mihoyo.com/avatar/avatar30060.png",
        userName: "西茗宜",
        userLevel: 11,
        comment: value,
        NowTime:time
      });
    },
  },
  filters:{
    Time(value) {
      let s = new Date(value);
      let m = s.getMonth() + 1;
      m = m < 10 ? "0" + m : m;
      let d = s.getDate();
      d = d < 10 ? "0" + d : d;
      return `${m}-${d}`
    },
  }
};
</script>

<style scoped>
.index{
  display: flex;
  width: 65%;
  /* background: black; */
  margin: 40px auto 60px;
  padding-top: 30px;
}
.main{
  width: 700px;
  /* background: #fff; */
  margin-right: 25px;
  margin-left: auto;
  margin-top: 30px;
}
.DataSide{
  text-align: center;
  width: 80px;
  padding: 0 10px;
  left: 8%;
  position: fixed;
  background: #fff;
  border-radius: 6px;
}
.DataSide li {
  padding: 15px 0;
  font-size: 13px;
  color: #999;
}
.DataSide li:nth-child(2) {
  border-bottom: 1px dashed #999;
  border-top: 1px dashed #999;
}
.DataSide li img {
  width: 40px;
}
.article{
  background: #fff;
  border-radius: 10px;
  padding: 40px 50px;
}
.title-mes>h3{
  font-size: 20px;
}
.title-model{
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #999;
  background: #f7f8fc;
  padding: 10px 8px;
}
.title-model>.model>span:nth-child(2){
  color:#fa0 ;
  margin-left: 10px;
}
.title-model ul{
  display: flex;
}
.title-model li{
  display: flex;
  align-items: center;
}
.title-model li img{
  width: 20px;
  margin-left:18px;
}
.title-time{
  margin-top: 16px;
  text-align: center;
  font-size: 14px;
  color: #999;
}
.article-main{
  margin-top: 20px;
  white-space:pre-wrap;
}
.article-main img{
  width: 80%;
}
.Com {
  border-radius: 10px;
  margin-top: 10px;
  background: #fff;
}
.ComItem {
  padding: 10px;
  border-bottom: 1px dashed #999;
}
.alide {
  width: 280px;
  margin-right: auto;
}
.alide .QR {
  width: 260px;
  padding: 10px;
  margin-top: 30px;
  background: #fff;
  border-radius: 10px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}
.alide .QR img {
  width: 100px;
  margin-right: 5px;
}
.alide .QR > div > p:first-child {
  color: #1fbbf4;
}
.Aswiper {
  margin-top: 20px;
}
.Aswiper .swiper {
  border-radius: 10px;
}
.Aswiper .swiper .swiper-slide-active {
  height: 160px;
}
.Aswiper img {
  width: 280px;
}
.hotTalk {
  margin-top: 20px;
  background: #fff;
  padding: 0px 20px 10px;
  border-radius: 10px;
}
.hotTalk ul li {
  /* width: 240px; */
  margin: 20px 8px;
  display: flex;
}
.hotTalk ul li .img {
  min-width: 75px;
  height: 50px;
  background-position: 50%;
  background-repeat: no-repeat;
  background-size: cover;
  border-radius: 10px;
  margin-right: 10px;
}
.hotTalk ul li div {
  height: 50px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hotTalk ul li div span {
  font-size: 12px;
  color: orange;
  border: 1px solid orange;
  border-radius: 6px;
  padding: 1px 1px;
  margin-right: 8px;
}
.hotTalk ul li div p {
  margin: 0;
  font-size: 13px;
  line-height: 25px;
  overflow: hidden;
}
</style>